/*
 * Copyright (c)  2020,  DataPipeline
 * All rights reserved.
 *
 * Id:InterceptorContext.java   2020-07-11 00:37 wanglijun
 */
package cn.datacare.orm.interceptor;

import cn.datacare.orm.engine.SQLParameter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * Title: 拦截器上下文
 * </p>
 * <p>
 * Description: 拦截器上下文
 * </p>
 * <p>
 * Copyright: Copyright (c) 2020
 * </p>
 * <p>
 * Company/Department: DataPipeline
 * </p>
 *
 * @author wanglijun
 * @version 1.0
 * @since 2020-07-11 00:37
 */
public class InterceptorContext {
    private String sqlId;
    private String sql;
    private List<SQLParameter> params;
    private Map<String, Object> env = null;
    private boolean isUpdate = false;
    private Object result;
    private Map<String, Object> inputParas;

    public InterceptorContext(String sqlId, String sql, List<SQLParameter> params, Map<String, Object> inputParas,
                              boolean isUpdate) {
        this.sql = sql;
        this.params = params;
        this.sqlId = sqlId;
        this.inputParas = inputParas;
        this.isUpdate = isUpdate;
    }

    public void put(String key, Object value) {
        if (env == null) {
            env = new HashMap<>();
        }
        env.put(key, value);
    }

    public Object get(String key) {
        if (env == null) {
            return null;
        } else {
            return env.get(key);
        }

    }

    public String getSql() {
        return sql;
    }



    public void setSql(String sql) {
        this.sql = sql;
    }

    public List<SQLParameter> getParams() {
        return params;
    }

    public String getSqlId() {
        return sqlId;
    }

    public boolean isUpdate() {
        return isUpdate;
    }

    public void setUpdate(boolean isUpdate) {
        this.isUpdate = isUpdate;
    }

    public Object getResult() {
        return result;
    }

    public void setResult(Object result) {
        this.result = result;
    }

    public Map<String, Object> getInputParas() {
        return inputParas;
    }
}
